<?php
class Pageley_Commerce_RemoveItemsFromOrderTests extends Pageley_Commerce_DomainTests {

        public function testRemoveItemFromOrder() {
        $success = $this->dispatchRequest(array(
            "controller" => "Commerce/AddItemToOrder",
            "articleId" => "1",
            "quantity" => "2"
        ));
        $this->assertTrue($success);
        $factory = Pageley_Controller_Session_Factory::getInstance();
        $session = $factory->getSession();
        $order = $session->get("commerce.order");
        $this->assertNotNull($order);
        $orderItems = $order->get("orderItems");
        $this->assertNotNull($orderItems);
        $this->assertEquals(1, $orderItems->size());
        $success = $this->dispatchRequest(array(
            "controller" => "Commerce/RemoveItemsFromOrder",
            "indices" => array("0")
        ));
        $this->assertTrue($success);
        $order = $session->get("commerce.order");
        $this->assertNotNull($order);
        $orderItems = $order->get("orderItems");
        $this->assertNotNull($orderItems);
        $this->assertEquals(0, $orderItems->size());
    }

	
}